//
//  Location.m
//  Bespoke
//
//  Created by Cheng on 12/8/2.
//
//

#import "Location.h"

@implementation Location
@synthesize Tf_Location,Bt_Location;
@synthesize delegate;


-(IBAction)locationButtonPressed:(id)sender {
    
    if ([Tf_Location.text isEqualToString:@""]) {
        
        UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Alert"
                                                           message:@"Please enter Address, City or Zip Code."
                                                          delegate:nil
                                                 cancelButtonTitle:@"Ok"
                                                 otherButtonTitles:nil];
        [alertView show];
        return;
    }
    [Tf_Location resignFirstResponder];
    [delegate DidSelected_Location:Tf_Location.text];
    Tf_Location.text = @"";
}

#pragma mark - UITextFieldDelegate

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    
    [self locationButtonPressed:self];
    return YES;
}

#pragma mark - Touches

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
    if( point.x > 0 && point.x < self.frame.size.width && point.y > 0 && point.y < self.frame.size.height )
    {
        [delegate uiViewTouched_Location:YES ];
        return YES;
    }
    
    [delegate uiViewTouched_Location:NO ];
    return NO;
}

@end
